<?php

namespace app\index\controller\consulting;

use app\index\service\MessageService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use ShidianUtil\Utils\CheckUtil;
use app\index\model\UM as UM;
use app\index\service\CommentMessageService;
use think\APP;
use think\Request as Request;

/**
 * CommentMessage 控制器
 * Class CommentMessage
 * @package app\index\controller\consulting;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\index\validate\consulting\CommentMessage
 */
class CommentMessage
{
    // 请求参数
    private Request $request;
    private MessageService $messageService;


    public function __construct(Request $request,  MessageService $messageService)
    {
        $this->request = $request;
        $this->messageService = $messageService;
    }

    /**
     * 发评价消息
     * @param UM $user
     * @return ApiResponse
     * @url /consulting/comment_message/save
     */
    public function save(UM $user): ApiResponse
    {
        $request     = $this->request;

        $this->messageService->addCommentConsultingMessage($user, $request->param());

        return ApiResponse::success(null);
    }

}
